#include "Utils.hpp"
#include <fstream>

namespace efs
{

std::string intToStr(int val)
{
	std::stringstream converter(std::stringstream::out);
	converter << val;
	return converter.str();
}

std::string intToStr(size_t val)
{
	return intToStr(static_cast<int>(val));
}

int strToInt(std::string const &str)
{
	std::stringstream converter(std::stringstream::out | std::stringstream::in);
	converter << str;
	int val = 0;
	converter >> val;
	return val;
}

int fileSize(std::string path)
{
	std::ifstream file(path.c_str(), std::ios::in | std::ios::binary);
 	if (file.is_open())
	{
 		file.seekg (0, std::ios::end);
 		return file.tellg();
 	}
 	else
 	{
 		return -1;
 	}
}

bool isFileBusy(std::string path)
{
	std::ofstream file(path.c_str(), std::ios::out | std::ios::binary);
 	if (file.is_open())
	{
 		return false;
 	}
 	else
 	{
 		return true;
 	}
}

}
